'''
Created on Apr 1, 2012

@author: wilshusensk
'''

def getSQLCommandSelectWhere(tableName, column, ComparingTo):
    cmd = "SELECT * FROM " + tableName + " WHERE " + column + " = " + "'" + ComparingTo + "'"
    return cmd
    
def getSQLCommandSelectDoubleWhere(tableName, firstColumn, firstCondition, firstComparingTo, secondColumn, secondCondition, secondComparingTo ):
    cmd = "SELECT * FROM " + tableName + " WHERE " + firstColumn + " " + firstCondition + " " + "" + firstComparingTo + " and " + secondColumn + " " + secondCondition + " " + "" + secondComparingTo + ""
    return cmd

def getSQLCommandSelectBetween(tableName, column, firstValue, secondValue):
    cmd = "SELECT * FROM " + tableName + " WHERE " + column + " BETWEEN " + " " + str(firstValue) + " and " + str(secondValue)
    return cmd    

def selectAllWhere(tableName, column, Condition):
    cmd = "SELECT * FROM " + tableName + " WHERE " + column + " = " + "'" + str(Condition) + "'"
    return cmd

def dropTable(tableName):
    cmd = "DROP TABLE " + tableName
    return cmd

def selectFrom(tableName, columns):
    if(columns[0] == "*"):
        cmd = "SELECT * FROM " + tableName
    else:
        cmd = "SELECT "
        for i in range(len(columns)):
            if(i > 0):
                cmd += ","
            cmd += "'"
            cmd += columns[i]
            cmd += "'"
        cmd += " FROM " + tableName
    return cmd

def createTable(tableName, fields):
    cmd = "CREATE TABLE " + tableName +"(" + ", ".join(fields) + ")"
    return cmd

def insertToTable(tableName, fields):
    cmd = "INSERT INTO " + tableName +" VALUES ("
    for i in range(len(fields)):
        if(i > 0):
            cmd += ","
        cmd += "'"
        cmd += fields[i]
        cmd += "'"
    cmd += ")"
    return cmd

def insertToTableNonAuto(tableName, name, website, declination, rightAscention):
    cmd = "INSERT INTO " + tableName +" VALUES ('" + name + "', '" + website + "', " + str(declination) + ", " + str(rightAscention) + ")"
    return cmd